*summary
sum GovExpratio Govemploy Govoutsourcing Expdecentral Subgovautonomy RealGDP Unemployrate Agedependratio Urbanization

*specify panelvar and timevar
destring Year, replace
xtset CountryNum Year, yearly

*multicollinearity test
pwcorr GovExpratio Govemploy Govoutsourcing Expdecentral Subgovautonomy RealGDP Unemployrate Agedependratio Urbanization
// no evidence of multicollinearity

*CSD test
xtcdf GovExpratio Govoutsourcing Expdecentral Subgovautonomy RealGDP Unemployrate Agedependratio Urbanization

xtcdf Govemploy Govoutsourcing Expdecentral Subgovautonomy RealGDP Unemployrate Agedependratio Urbanization
//evidence of CSD

*unit root test Pesaran (2007)
pescadf GovExpratio, lags(2)
pescadf Govemploy, lags(2)
pescadf Govoutsourcing, lags(2)
pescadf Expdecentral, lags(2)
pescadf Subgovautonomy, lags(2)
pescadf RealGDP, lags(2)
pescadf Unemployrate, lags(2)
pescadf Agedependratio, lags(2)
pescadf Agedependratio, lags(2)
//cannot reject the presence of unit root

************************************************************************
***Government expenditure ratio as DV

quietly{
	*clean missing data
	egen nmiss=rmiss(GovExpratio Govoutsourcing Expdecentral Subgovautonomy RealGDP Unemployrate Agedependratio Urbanization)
tab nmiss
keep if nmiss==0

*transform to a first difference model
gen diff_GovExpratio = GovExpratio - L.GovExpratio  
gen diff_Govoutsourcing = Govoutsourcing - L.Govoutsourcing 
gen diff_Expdecentral = Expdecentral - L.Expdecentral 
gen diff_Subgovautonomy = Subgovautonomy - L.Subgovautonomy 
gen diff_RealGDP = RealGDP - L.RealGDP 
gen diff_Unemployrate = Unemployrate - L.Unemployrate 
gen diff_Agedependratio = Agedependratio - L.Agedependratio 
gen diff_Urbanization = Urbanization - L.Urbanization  

**lose the first observation in every panel (totally 14)

*Clean missing data
egen nnmiss=rmiss(diff_GovExpratio diff_Govoutsourcing diff_Expdecentral diff_Subgovautonomy diff_RealGDP diff_Unemployrate diff_Agedependratio diff_Urbanization)
tab nnmiss
keep if nnmiss==0
}

**first difference model

*OLS with PCSE in first difference model
xtpcse diff_GovExpratio diff_Govoutsourcing diff_Expdecentral diff_Subgovautonomy diff_RealGDP diff_Unemployrate diff_Agedependratio diff_Urbanization i.CountryNum i.Year, correlation(psar1) rhotype(tscorr)


*OLS with FGLS in first difference model
xtgls diff_GovExpratio diff_Govoutsourcing diff_Expdecentral diff_Subgovautonomy diff_RealGDP diff_Unemployrate diff_Agedependratio diff_Urbanization i.CountryNum i.Year, panels(iid) corr(psar1)

*For model 5 & 6
xtpcse diff_GovExpratio diff_Govoutsourcing diff_Expdecentral diff_Subgovautonomy diff_RealGDP diff_Unemployrate diff_Agedependratio diff_Urbanization i.CountryNum i.Year, corr(ar1)

xtgls diff_GovExpratio diff_Govoutsourcing diff_Expdecentral diff_Subgovautonomy diff_RealGDP diff_Unemployrate diff_Agedependratio diff_Urbanization i.CountryNum i.Year, corr(ar1)


******************************************************************************************
***Government employment as DV***


quietly{
	*clean missing data
	egen nmiss=rmiss(Govemploy Govoutsourcing Expdecentral Subgovautonomy RealGDP Unemployrate Agedependratio Urbanization)
tab nmiss
keep if nmiss==0

*transform to a first difference model
gen diff_Govemploy = Govemploy - L.Govemploy
gen diff_Govoutsourcing = Govoutsourcing - L.Govoutsourcing 
gen diff_Expdecentral = Expdecentral - L.Expdecentral 
gen diff_Subgovautonomy = Subgovautonomy - L.Subgovautonomy 
gen diff_RealGDP = RealGDP - L.RealGDP 
gen diff_Unemployrate = Unemployrate - L.Unemployrate 
gen diff_Agedependratio = Agedependratio - L.Agedependratio 
gen diff_Urbanization = Urbanization - L.Urbanization 

**lose the first observation in every panel (totally 14)

*Clean missing data
egen nnmiss=rmiss(diff_Govemploy diff_Govoutsourcing diff_Expdecentral diff_Subgovautonomy diff_RealGDP diff_Unemployrate diff_Agedependratio diff_Urbanization)
tab nnmiss
keep if nnmiss==0
}

**first difference model

*OLS with PCSE in first difference model
xtpcse diff_Govemploy diff_Govoutsourcing diff_Expdecentral diff_Subgovautonomy diff_RealGDP diff_Unemployrate diff_Agedependratio diff_Urbanization i.CountryNum i.Year, correlation(psar1) rhotype(tscorr)


*OLS with FGLS in first difference model
xtgls diff_Govemploy diff_Govoutsourcing diff_Expdecentral diff_Subgovautonomy diff_RealGDP diff_Unemployrate diff_Agedependratio diff_Urbanization i.CountryNum i.Year, panels(iid) corr(psar1)

